﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coldairarrow.Business.Base_Company;
using Coldairarrow.Business.Base_Manage;
using Coldairarrow.ResResult;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.Statistics_Info
{
    [Route("/Statistics_Info/[controller]/[action]")]
    public class Statistics_InfoController : BaseApiController
    {
        readonly IBTB_Company_VisitLogBusiness _cvsBus;
        readonly IBase_RoleBusiness _roleBus;
        public Statistics_InfoController(
           IBTB_Company_VisitLogBusiness cvsBus,
           IBase_RoleBusiness roleBus

           )
        {
            _cvsBus = cvsBus;
            _roleBus = roleBus; ;
        }
        #region 获取

        /// <summary>
        /// 首页总汇总信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object GetIndexSumData()
        {
            ResJsonResult res = new ResJsonResult();

            try
            {
                var isAdmin = _roleBus.IsAdmRole();
                if (isAdmin)
                {
                    //站点管理员

                    ////站点今日总发布量
                    //var tdCount = _ctnBus.GetTheDayount(1, 0);

                    ////站点总发布量
                    //var pbCount = _ctnBus.GetTheDayount(0, 0);

                    //PV总量
                    var pvCount = _cvsBus.GetPVCount();

                    //UV总量
                    var uvCount = _cvsBus.GetPVCount();

                    //IP总量
                    var ipCount = _cvsBus.GetPVCount();

                    ////留言总数
                    //var msCount = _lmfs.GetMessageCount(0);

                    ////待回复总数
                    //var dmsCount = _lmfs.GetMessageCount(1);

                    var obj = new
                    {
                        Type = 1,
                        SumData = new
                        {
                            //TDCount = tdCount,
                            //PBCount = pbCount,
                            PVCount = pvCount,
                            UVCount = uvCount,
                            IPCount = ipCount
                            //MessageCount = msCount,
                            //DMessageCount = dmsCount
                        }
                    };

                    res.data = obj;
                }
                //else
                //{
                //    //普通管理员

                //    //个人今日总发布量
                //    var tdCount = _ctnBus.GetTheDayount(1, 1);

                //    //个人审核通过量
                //    var psCount = _ctnBus.GetContentPasscount();

                //    //个人总发布量
                //    var pbCount = _ctnBus.GetTheDayount(0, 1);

                //    //个人文章访问量
                //    var visitCount = _ctnBus.GetVisitCount();

                //    var obj = new
                //    {
                //        Type = 0,
                //        SumData = new
                //        {
                //            TDCount = tdCount,
                //            PSCount = psCount,
                //            PBCount = pbCount,
                //            VisitCount = visitCount
                //        }
                //    };

                //    res.data = obj;
                //}

                res.success = true;
            }
            catch (Exception ex)
            {
                res.message = ex.Message;
            }

            return res;
        }


        /// <summary>
        /// 后台——用户积分消费记录查看
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetsPointLog(PageInput<SearchDTO> input)
        {
            return await _cvsBus.GetPointLog(input);
        }

        /// <summary>
        /// 后台——用户积分消费记录详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public PointLogDTO GetsThePointData(IdInputDTO input)
        {
            return  _cvsBus.GetUThePointData(input);
        }

        /// <summary>
        ///  后台——用户消费券记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetsTicketLog(PageInput<TKTSearchDTO> input)
        {
            return await _cvsBus.GetTicketLog(input);
        }

        /// <summary>
        /// 后台——用户消费券详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public UserTicketLogDTO GetsTheTicketLogData(IdInputDTO input)
        {
            return _cvsBus.GetTheTicketLogData(input);
        }

        /// <summary>
        ///  后台——获取用户收益记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetsUserRebateLog(PageInput<RBTSearcDTO> input)
        {
            return await _cvsBus.GetUserRebateLogs(input);
        }

        /// <summary>
        /// 后台——获取用户收益/提现记录详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public UserRebateLogDTO GetsTheUserRebateLogData(IdInputDTO input)
        {
            return  _cvsBus.GetTheUserRebateLogData(input);
        }

        /// <summary>
        ///  后台——获取用户收益统计数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetsUserRebateDataAsnyc(PageInput<SearchDTO> input)
        {
            return await _cvsBus.GetUserRebateDataAsnyc(input);
        }

        /// <summary>
        ///  后台——获取用户收益统计数据详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public UserProfitDTO GetsTheUserRebateData(IdInputDTO input)
        {
            return  _cvsBus.GetTheUserRebateData(input);
        }


        #endregion
    }
}
